#include <algorithm>
#include <climits>
#include <vector>
using namespace std;

class Solution
{
public:
    static int maxProfit(vector<int>& prices)
    {
        int minprice = INT_MAX;
        int maxProfit = 0;

        for(auto price : prices)
        {
            minprice = min(minprice, price);
            maxProfit = max(maxProfit, price - minprice);
        }
        return maxProfit;
    }
};
